<template>
    <div class="app-container">
        <div id="chart" class="chart" style="height:500px;" />
    </div>
</template>
<script>

import echarts from 'echarts'
import honorApi from '@/api/honor/honor'

export default {
    data() {
        return {
            
        }
    },
    created() {
        this.showChart()
    },
    methods: {
        showChart(){
            honorApi.findHonorCount()
            .then((response) =>{
                this.setChartData(response.data)
            })
        },
        setChartData(data) {
            // 基于准备好的dom，初始化echarts实例
            var myChart = echarts.init(document.getElementById('chart'))
            // 指定图表的配置项和数据
            var option = {
                title: {
                    text: '国际级荣誉统计'
                    },
                xAxis: {
                    data: data.xData
                },
                yAxis: {
                    minInterval: 1
                },
                series: [{
                    type: 'line',
                    data: data.yData,
                    smooth: true
                }]
            }
            // 使用刚指定的配置项和数据显示图表。
            myChart.setOption(option)
            },
        },
}
</script>